package com.demo.interceptor;

import org.apache.ibatis.executor.resultset.ResultSetHandler;
import org.apache.ibatis.plugin.*;
import org.springframework.stereotype.Component;
import java.sql.Statement;
import java.util.Properties;

@Component
@Intercepts({@Signature(type = ResultSetHandler.class, method = "handleResultSets", args = {Statement.class})})
public class ResultSetHandlerInterceptor implements Interceptor {

    @Override
    public Object intercept(Invocation invocation) throws Throwable {
        System.out.println("ResultSetHandlerInterceptor-invocation---前置");
        Object proceed = invocation.proceed();
        System.out.println("ResultSetHandlerInterceptor-invocation---后置");
        return proceed;
    }

//    @Override
//    public Object plugin(Object target) {
//        System.out.println("ResultSetHandlerInterceptor-plugin---target：" + target.getClass());
//        return Plugin.wrap(target, this);
//    }

    @Override
    public void setProperties(Properties properties) {
        System.out.println("ResultSetHandlerInterceptor-setProperties---");
    }
}
